﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;

namespace LD24.Helpers
{
    public class KeyboardHelper
    {
        private static KeyboardState _oldKeyboard;
        private static KeyboardState _keyboard;


        public static void Update()
        {
            if(_keyboard != null)
                _oldKeyboard = _keyboard;

            _keyboard = Keyboard.GetState();
        }


        public static Boolean isKeyDown(Keys key)
        {
            return _keyboard.IsKeyDown(key);
        }

        public static Boolean isKeyUp(Keys key)
        {
            return _keyboard.IsKeyUp(key);
        }

        public static Boolean isKeyPressed(Keys key)
        {
            return _keyboard.IsKeyDown(key) && _oldKeyboard.IsKeyUp(key);
        }

        public static Boolean isKeyReleased(Keys key)
        {
            return _keyboard.IsKeyUp(key) && _oldKeyboard.IsKeyDown(key);
        }
    }
}
